package com.db.manage.datasource;

import com.alibaba.druid.pool.DruidDataSource;
import com.db.manage.model.ConnectionConfig;
import org.springframework.stereotype.Component;

import javax.sql.DataSource;

@Component
public class OracleAdapter implements DatabaseAdapter {
    @Override
    public DataSource createDataSource(ConnectionConfig config) {
        DruidDataSource dataSource = new DruidDataSource();
        dataSource.setUrl(config.getUrl());
        dataSource.setUsername(config.getUsername());
        dataSource.setPassword(config.getPassword());
        dataSource.setDriverClassName("oracle.jdbc.OracleDriver");
        // 设置连接池参数
        dataSource.setInitialSize(5);
        dataSource.setMinIdle(5);
        dataSource.setMaxActive(20);
        dataSource.setMaxWait(60000);
        return dataSource;
    }

    @Override
    public boolean testConnection(ConnectionConfig config) {
        return false;
    }

    @Override
    public String getDbType() {
        return "oracle";
    }
} 